﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ECONTACT.DataLayer
{
    public class KhoiLopData
    {
        DataService m_KhoiLopData = new DataService();

        public DataTable LayDsKhoiLop()
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM KHOILOP");
            m_KhoiLopData.Load(cmd);
            return m_KhoiLopData;
        }

        public void LuuKhoiLop(String Ten)
        {
            SqlCommand cmd = new SqlCommand("sp_ThemKhoiLop");

            cmd.Parameters.Add("@TenKhoi", SqlDbType.NVarChar).Value = Ten;

            m_KhoiLopData.LoadProc(cmd);
        }

        public void UpdateKhoiLop(String MaKhoi, String Ten)
        {
            SqlCommand cmd = new SqlCommand("sp_CapNhatKhoiLop");

            cmd.Parameters.Add("@MaKhoi", SqlDbType.NVarChar).Value = MaKhoi;
            cmd.Parameters.Add("@TenKhoi", SqlDbType.NVarChar).Value = Ten;

            m_KhoiLopData.LoadProc(cmd);
        }

        public void DeleteKhoiLop(String MaKhoi)
        {
            SqlCommand cmd = new SqlCommand("sp_XoaKhoiLop");

            cmd.Parameters.Add("@MaKhoi", SqlDbType.NVarChar).Value = MaKhoi;

            m_KhoiLopData.LoadProc(cmd);
        }
    }
}
